import {getOrders,putOrdersId} from '@/api/orders'
const state={
     //发送请求的参数
     pagination:{
        query:'',
        //当前页码	
        pagenum:1,
        //每页显示条数
        pagesize:5,
    },
    //响应后取到的pagination数据
    paginationData:{
        //总页数
        total:null,
        //当前用户列表
        goods:[],
        pagenum:''
    },
    //当前行的值
    currentRow:{}
};
const getters={
    
};
const mutations={
    //发送请求的参数
    CHANGE_PAGINATION(state,playLoad){
        for(let key in playLoad){
            state.pagination[key]=playLoad[key]
        }
    },
    //响应后取到的pagination数据
    CHANGE_PAGINATIONDATA(state,playLoad){
        for(let key in playLoad){
            state.paginationData[key]=playLoad[key]
        }
    },
    //修改当前行
     CHANGE_CURRENTROW(state,playLoad){
       state.currentRow=playLoad;
     },
};
const actions={
    Acs_getOrders(content,playLoad){
        return new Promise((resolve,reject)=>{
            getOrders(playLoad).then(res=>{
                resolve(res);
                content.commit('CHANGE_PAGINATIONDATA',res)
            }).catch(err=>{
                reject(err)
            })
        })
    },
    Acs_putOrdersId(content,playLoad){
        return new Promise((resolve,reject)=>{
            putOrdersId(playLoad).then(res=>{
                resolve(res);
            }).catch(err=>{
                reject(err)
            })
        })
    },
   

};
export default {
    namespaced:true,
    state,
    getters,
    mutations,
    actions
}